package com.guhecloud.step.definition.runtime;

import com.guhecloud.step.definition.runtime.def.StepDef;
import com.sun.istack.internal.NotNull;

import java.util.ArrayList;
import java.util.List;

public final class Center {
    private Center() {}

    /**
     * 查询领域能力实例
     * @param domainAbilityClazz
     * @return
     * @param <T>
     */
    @NotNull
    public static <T extends BaseDomainAbility> T findAbility(@NotNull Class<? extends T> domainAbilityClazz) {
        return InternalIndexer.findDomainAbility(domainAbilityClazz);
    }

    @NotNull
    public static <Step extends IDomainStep> List<Step> findSteps(@NotNull String activityCode, @NotNull List<String> stepCodeList) {
        List<StepDef> stepDefs = InternalIndexer.findDomainSteps(activityCode, stepCodeList);
        List<Step> result = new ArrayList<>(stepDefs.size());
        for (StepDef stepDef : stepDefs) {
            result.add((Step) stepDef.getStepBean());
        }

        return result;
    }

}
